import Vue from 'vue'
import { Toast } from 'cube-ui'

Vue.use(Toast)
let toast

export function showError (txt) {
  if (!txt) {
    txt = '错误'
  }
  toast = Toast.$create({
    type: 'error',
    txt: txt

  })
  toast.show()
}

export function showLoading (txt) {
  if (!txt) {
    txt = ''
  }
  toast = Toast.$create({
    txt: txt,
    mask: true
  })
  toast.show()
}

export function showInfo (txt, type) {
  if (!type) {
    type = txt
  }
  if (!txt) {
    txt = '错误'
  }
  toast = Toast.$create({
    type: type,
    txt: txt

  })
  toast.show()
}

export function hide () {
  if (toast) {
    toast.hide()
  }
}

// export function showAlter (txt) {
//   toast = Toast.$create
//   this.addressPicker = this.$createCascadePicker({
//     title: '选择地址',
//     data: addressData,
//     onSelect: this.selectHandle,
//     onCancel: this.cancelHandle
//   })
// }
